<?php
session_start();
include_once("config.php");
checkLoggedIn("yes");

if(isset($_POST["submit"]))
{
//	# field_validator($field_descr, $field_data, $field_type, $min_length="", $max_length="", $field_required=1) 
	
		//field_validator("login name", $_POST["login"], "alphanumeric", 1, 15);
		field_validator("password", $_POST["password"], "string", 4, 15);
		field_validator("confirmation password", $_POST["password2"], "string", 4, 15);

		if(strcmp($_POST["password"], $_POST["password2"])) 
		{
			$messages[]="Your passwords did not match";
		}
		if(empty($messages)) 
		{
			changePwd($_SESSION["login"], $_POST["password"]);
			cleanMemberSession($_SESSION["login"], $_POST["password"]);
			header("Location: members.php");
		}
}
?>

<html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php print $title; ?></title>
</head>
<style type="text/css">
<!--
@import url("style.css");
-->
</style>
<body>
<?php
echo "<div class=\"body\">";
//Check if $message is set, and output it if it is:
if(!empty($messages)){
	displayErrors($messages);
}
?>
<form action="<?php print $_SERVER["PHP_SELF"]; ?>" method="POST">
<table>
<tr><td>Usuario:</td><td><?php print $_SESSION["login"]; ?></td>
<tr><td>Password:</td><td><input type="password" name="password" value="" maxlength="15"></td></tr>
<tr><td>Confirmar password:</td><td><input type="password" name="password2" value="" maxlength="15"></td></tr>
<tr><td>&nbsp;</td><td><input name="submit" type="submit" value="Submit"></td></tr>
</table>
</form>
</div>
</body>
</html>

